package cn.walls1717.service.impl;

import cn.walls1717.domain.Orders;
import cn.walls1717.mapper.OrdersMapper;
import cn.walls1717.service.OrdersService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author CJ
 * @date 2020/8/5
 */
@Service
@Transactional(rollbackFor=Exception.class)
public class OrdersServiceImpl implements OrdersService {

    private OrdersMapper ordersMapper;

    @Autowired
    public void setOrdersMapper(OrdersMapper ordersMapper) {
        this.ordersMapper = ordersMapper;
    }

    /**
     * 查询所有订单
     * @return 所有订单
     */
    @Override
    public List<Orders> findAll(Integer page, Integer size) throws Exception {
        // 参数 pageNum 是页码值，pageSize 代表每页显示条数(必须写在调用分页的代码之前)
        PageHelper.startPage(page, size);
        return ordersMapper.findAll();
    }

    @Override
    public Orders findById(String ordersId) throws Exception {
        return ordersMapper.findById(ordersId);
    }
}
